<ot-view>

    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title">
                        Configuration
                    </div>
                </div>
                <div class="panel-body">
                    <p>
                        Configuration type:
                        <b>{{gitSyncInfo.type}}</b>
                    </p>
                    <p>
                        Configuration name:
                        <b>{{gitSyncInfo.name}}</b>
                    </p>
                    <p>
                        Git remote URL:
                        <b>{{gitSyncInfo.remote}}</b>
                    </p>
                    <p>
                        Automatic indexation:
                        <b ng-if="gitSyncInfo.indexationInterval <= 0">None</b>
                        <b ng-if="gitSyncInfo.indexationInterval > 0">Every {{gitSyncInfo.indexationInterval}}
                            minute<span ng-if="gitSyncInfo.indexationInterval > 1">s</span></b>
                    </p>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title">
                        Synchronisation actions
                    </div>
                </div>
                <table class="table table-hover table-condensed">
                    <tr ng-if="project._gitSync">
                        <td>
                            <!-- Synchronise action -->
                            <button type="button" class="btn btn-info" ng-click="projectSync(false)" ng-disabled="synchronising">
                                <span class="fa fa-download"></span>
                                Synchronise
                            </button>
                        </td>
                        <td>
                            Gets the latest commits from the remote repository. No reset done. The repository
                            might have to be cloned first if not already done.
                        </td>
                    </tr>
                    <tr ng-if="project._gitSync">
                        <td>
                            <!-- Reset action -->
                            <button type="button" class="btn btn-warning" ng-click="projectSync(true)" ng-disabled="synchronising">
                                <span class="fa fa-refresh"></span>
                                Reset
                            </button>
                        </td>
                        <td>
                            Resets the repository and clones it from scratch. This can take some time, depending
                            on the size of the repository.
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a href="#/project/{{project.id}}" class="btn btn-link">
                                <span class="fa fa-times"></span>
                                Close
                            </a>
                        </td>
                        <td>
                            Returns to the project page without doing anything.
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title">
                        Synchronisation status
                    </div>
                </div>
                <div class="panel-body" ng-if="gitSyncInfo.status == 'NONE'">
                    <div class="alert alert-warning">
                        No synchronisation was ever done for this repository. Please synchronise in order to
                        be able to extract Git related information.
                    </div>
                </div>
                <div class="panel-body" ng-if="gitSyncInfo.status == 'RUNNING'">
                    <div class="alert alert-info">
                        Synchronisation is currently running. Please refresh later to get the latest information.
                    </div>
                </div>
                <table class="table table-condensed table-hover" ng-if="gitSyncInfo.status == 'IDLE'">
                    <thead>
                    <tr>
                        <th>Branch</th>
                        <th>Commit</th>
                        <th>Author</th>
                        <th>Time</th>
                        <th>Message</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="branch in gitSyncInfo.branches">
                        <td><b>{{branch.name}}</b></td>
                        <td><code>{{branch.commit.shortId}}</code></td>
                        <td>{{branch.commit.author.name}}</td>
                        <td>
                            {{branch.commit.commitTime | date:'mediumDate'}}
                            {{branch.commit.commitTime | date:'shortTime'}}
                        </td>
                        <td>
                            {{branch.commit.shortMessage}}
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</ot-view>